package com.payment.ktb.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.payment.ktb.R;
import com.payment.ktb.constants.ConstantsOrderManage;
import com.payment.ktb.constants.ConstantsPayType;
import com.payment.ktb.constants.ConstantsProfitWithdrawStatus;
import com.payment.ktb.model.OrderManageEntity;
import com.payment.ktb.model.ProfitWithdrawEntity;
import com.payment.ktb.utils.StringUtils;

import java.util.List;

/**
 * Created by admin on 2017/9/22.
 */

public class ProfitWithdrawAdapter extends BaseAdapter {

    private Context mContext;
    private List<ProfitWithdrawEntity> listdatas;

    public ProfitWithdrawAdapter(Context mContext, List<ProfitWithdrawEntity> listdatas) {
        this.mContext = mContext;
        this.listdatas = listdatas;
    }

    public ProfitWithdrawAdapter() {
    }

    @Override
    public int getCount() {
        return listdatas.size();
    }

    @Override
    public Object getItem(int i) {
        return listdatas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder = null;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = View.inflate(mContext, R.layout.adapter_profitwithdraw_item,null);
            viewHolder.tv_profitwithdraw_orderReqTime = (TextView) view.findViewById(R.id.tv_profitwithdraw_orderReqTime);
            viewHolder.tv_profitwithdraw_orderStatus = (TextView) view.findViewById(R.id.tv_profitwithdraw_orderStatus);
            viewHolder.tv_profitwithdraw_orderPrice = (TextView) view.findViewById(R.id.tv_profitwithdraw_orderPrice);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.tv_profitwithdraw_orderReqTime.setText(listdatas.get(i).getOrderReqTime());
        if (ConstantsProfitWithdrawStatus.SUCC.getCode() == listdatas.get(i).getOrderStatus()) {
            viewHolder.tv_profitwithdraw_orderStatus.setTextColor(mContext.getResources().getColor(R.color.green));
        }else if (ConstantsProfitWithdrawStatus.FAIL.getCode() == listdatas.get(i).getOrderStatus()) {
            viewHolder.tv_profitwithdraw_orderStatus.setTextColor(mContext.getResources().getColor(R.color.red));
        }else if (ConstantsProfitWithdrawStatus.INIT.getCode() == listdatas.get(i).getOrderStatus()) {
            viewHolder.tv_profitwithdraw_orderStatus.setTextColor(mContext.getResources().getColor(R.color.orange));
        }else {
            viewHolder.tv_profitwithdraw_orderStatus.setTextColor(mContext.getResources().getColor(R.color.text666666));
        }
        viewHolder.tv_profitwithdraw_orderStatus.setText(ConstantsProfitWithdrawStatus.getDesc(listdatas.get(i).getOrderStatus()));
        viewHolder.tv_profitwithdraw_orderPrice.setText("¥" + StringUtils.handleFen2Yuan(listdatas.get(i).getOrderPrice()));
        return view;
    }


    class ViewHolder {
        TextView tv_profitwithdraw_orderReqTime;
        TextView tv_profitwithdraw_orderStatus;
        TextView tv_profitwithdraw_orderPrice;

    }

}
